package com.zjitc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zjitc.dao.CategoryDao;
import com.zjitc.dao.ProductDao;
import com.zjitc.model.Category;
import com.zjitc.model.CategorySecond;
import com.zjitc.model.Evaluate;
import com.zjitc.model.Product;
import com.zjitc.service.ProductService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/4/25 16:23
 * @description:
 */
@Service
public class ProductServiceImpl implements ProductService{

  @Autowired
  private ProductDao productDao;

  @Autowired
  private CategoryDao categoryDao;

  @Override
  public List<Category> findAllCategory() {
    List<Category>list=categoryDao.findAllCategory();
    for(Category c:list) {
      List<CategorySecond> cslist=productDao.findByCid(c.cid);
      c.setCategorySecondList(cslist);
    }
    return list;
  }

  @Override
  public List<Product> findPageByCid(int cid) {
    return productDao.findPageByCid(cid);
  }

  @Override
  public List<Product> findPageByCsid(int csid) {
    return productDao.findPageByCsid(csid);
  }

  @Override
  public List<Product> findAllProductByPage() {
    return productDao.findAllProductByPage();
  }


  @Override
  public Product findProductById(int pid) {
    return productDao.findProductById(pid);
  }


  @Override
  public List<Product> findAllProduct() {
    return productDao.findAllProduct();
  }
}
